//
//  ZCommentCell.m
//  WeClubs
//
//  Created by Zed Link on 10/4/2017.
//  Copyright © 2017 Zed. All rights reserved.
//

#import "ZCommentCell.h"
#import "ZClientInfoCenter.h"
#import <UIImageView+WebCache.h>

@interface ZCommentCell ()

@property (weak, nonatomic) IBOutlet UIImageView *logoImgView;
@property (weak, nonatomic) IBOutlet UILabel *userLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;

@end

@implementation ZCommentCell

- (void)zSetupCell
{
    [super zSetupCell];
    
    [self.logoImgView zCornerDeal:18];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.separatorInset = UIEdgeInsetsMake(0, 52, 0, 0);
    
    [self.contentView setBackgroundColor:NAVBAR_BG_COLOR];
}

- (void)updateCell
{
    self.userLabel.text = self.commentModel.studentName;
    self.contentLabel.text = self.commentModel.content;
    self.dateLabel.text = [[ZClientInfoCenter sharedInstance] stringByFormatt:@"MM-dd HH:mm" fromMilliSeconds:self.commentModel.createDate];
    
    NSString *avatarUrl = self.commentModel.studentAvatar;
    if (avatarUrl != nil) {
        [self.logoImgView sd_setImageWithURL:[NSURL URLWithString:avatarUrl]];
    }
}

- (void)setCommentModel:(ZCommentModel *)commentModel
{
    _commentModel = commentModel;
    
    [self updateCell];
}

@end
